package org.nf.shopping.controller;


import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.nf.shopping.common.vo.RoleVO;
import org.nf.shopping.common.vo.ResultVO;
import org.nf.shopping.entity.Role;
import org.nf.shopping.service.RoleService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author lxy
 * @Date 2024-10-15
 */
@RestController
@RequiredArgsConstructor
public class LoginController extends BaseController{
    private final RoleService roleService;

    @PostMapping("/login")
    public ResultVO<Role> login(@Valid RoleVO roleVO){
        Role role = new Role();
        BeanUtils.copyProperties(roleVO,role);
        Role role1 = roleService.auth(role);
        return success(role1);
    }
}
